package com.xmxsuperstar.app.client.twitter;

import java.util.List;

import net.love5z.common.utils.StringUtils;

import com.xmxsuperstar.app.client.twitter.model.TwitterStatus;

public class TwitterListTimeLineClient extends TwitterTimeLineClient {

	private final long listId;

	public TwitterListTimeLineClient(long listId) {
		this.listId = listId;
	}

	@Override
	protected String getBaseUrlStr() {
		return "http://api.twitter.com/1/lists/statuses.json";
	}

	@Override
	public List<TwitterStatus> getTimeLine(int count) {
		String param1 = StringUtils
				.contact("=", "count", String.valueOf(count));
		String param2 = StringUtils.contact("=", "list_id",
				String.valueOf(listId));
		String params = StringUtils.contact("&", param1, param2);
		String requestUrl = StringUtils.contact("?", this.getBaseUrlStr(),
				params);

		String response = this.get(requestUrl);

		return parase(response);
	}

	@Override
	public List<TwitterStatus> getTimeLineBySinceId(long sinceId, int count) {
		String param1 = StringUtils.contact("=", "since_id",
				String.valueOf(sinceId));
		String param2 = StringUtils
				.contact("=", "count", String.valueOf(count));
		String param3 = StringUtils.contact("=", "list_id",
				String.valueOf(listId));
		String params = StringUtils.contact("&", param1, param2, param3);
		String requestUrl = StringUtils.contact("?", this.getBaseUrlStr(),
				params);

		String response = this.get(requestUrl);

		return parase(response);
	}

	@Override
	public List<TwitterStatus> getTimeLineByMaxId(long maxId, int count) {
		String param1 = StringUtils.contact("=", "max_id",
				String.valueOf(maxId));
		String param2 = StringUtils
				.contact("=", "count", String.valueOf(count));
		String param3 = StringUtils.contact("=", "list_id",
				String.valueOf(listId));
		String params = StringUtils.contact("&", param1, param2, param3);
		String requestUrl = StringUtils.contact("?", this.getBaseUrlStr(),
				params);

		String response = this.get(requestUrl);

		return parase(response);

	}

}
